package com.zzyl.intercept.mvc;

import com.zzyl.intercept.interceptor.AuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description WebConfig
 * @Author chun jiang
 * @Date 2024-07-09
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthInterceptor())
                .addPathPatterns("/**")  // 拦截所有路径
                .excludePathPatterns("/login");  // 除了登录页面之外的路径都会被拦截
    }
}